﻿#include <iostream>
#include <cmath>
using namespace std;

class Triangle {
private:
	double a, b, c;

public:
	void Init(double sideA, double sideB, double sideC) {
		a = sideA;
		b = sideB;
		c = sideC;
	}
	bool isTriangle() {
		return (a + b > c) && (a + c > b) && (b + c > a);
	}
	void setSideA(double sideA) {
		a = sideA;
	}
	void setSideB(double sideB) {
		b = sideB;
	}
	void setSideC(double sideC) {
		c = sideC;
	}
	double getSideA() { return a; }
	double getSideB() { return b; }
	double getSideC() { return c; }
	double perimeter() {
		if (isTriangle()) {
			return a + b + c;
		}
		else {
			cout << "这不是一个有效的三角形!" << endl;
			return -1;
		}
	}
	double area() {
		if (isTriangle()) {
			double p = perimeter() / 2;
			return sqrt(p * (p - a) * (p - b) * (p - c));
		}
		else {
			cout << "这不是一个有效的三角形!" << endl;
			return -1;
		}
	}
	int typeTriangle() {
		if (!isTriangle()) {
			cout << "这不是一个有效的三角形!" << endl;
			return -1;
		}
		if (a == b && b == c) {
			return 3;
		}
		else if (a == b || b == c || a == c) {
			return 2; 
		}
		else {
			return 1; 
		}
	}
	bool isRightAngle() {
		if (!isTriangle()) return false;
		if (a > b && a > c) return (b * b + c * c == a * a);
		if (b > a && b > c) return (a * a + c * c == b * b);
		return (a * a + b * b == c * c);
	}
};
int main() {
	Triangle t;
	t.Init(3, 4, 5);

	if (t.isTriangle()) {
		cout << "周长: " << t.perimeter() << endl;
		cout << "面积: " << t.area() << endl;
		int type = t.typeTriangle();
		if (type == 1) cout << "不等边三角形" << endl;
		else if (type == 2) cout << "等腰三角形" << endl;
		else if (type == 3) cout << "等边三角形" << endl;
		if (t.isRightAngle()) {
			cout << "直角三角形" << endl;
		}
		else {
			cout << "不是直角三角形" << endl;
		}
	}
	else {
		cout << "这不是一个有效的三角形。" << endl;
	}
	return 0;
}
